﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace syc.Fc.报表
{
    public class BaohuqiJinDuMonthData
    {
        public double[] Data = new double[200];

        public void QueryData(int fenchang, int chanpin, DateTime d1, DateTime d2, DateTime d3)
        {

            SqlConnection Conn = new SqlConnection();
            Conn.ConnectionString = ConfigurationManager.ConnectionStrings["SCMConnectionString1"].ConnectionString;
            Conn.Open();
            SqlCommand Cmd = new SqlCommand();
            Cmd.Connection = Conn;
            Cmd.CommandText = "保护器生产月报数据";
            Cmd.CommandType = CommandType.StoredProcedure;


            Cmd.Parameters.Add(new SqlParameter("@分厂ID", SqlDbType.Int, 4, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, fenchang));
            Cmd.Parameters.Add(new SqlParameter("@产品类别ID", SqlDbType.Int, 4, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, chanpin));
            Cmd.Parameters.Add(new SqlParameter("@d1", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, d1));
            Cmd.Parameters.Add(new SqlParameter("@d2", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, d2));
            Cmd.Parameters.Add(new SqlParameter("@d3", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, d3));

            SqlDataReader Reader = Cmd.ExecuteReader();
            int x = 0;
            int gongduan;
            while (Reader.Read())
            {
                if (Reader.IsDBNull(2)) continue;
                x = ((int)Reader["类别"] - 1) * 100;

                gongduan = (int)Reader["工段"];
                x += (gongduan - 1) * 25;

                Data[x + 0] = (double)Reader["投入塑质"];
                Data[x + 1] = (double)Reader["投入铁质"];
                Data[x + 2] = (int)Reader["内套"];
                Data[x + 3] = (int)Reader["外套"];
                Data[x + 4] = (int)Reader["内套废"];
                Data[x + 5] = (int)Reader["外套废"];
                Data[x + 6] = (int)Reader["注塑1"];
                Data[x + 7] = (int)Reader["注塑2"];
                Data[x + 8] = (int)Reader["注塑3"];
                Data[x + 9] = (int)Reader["注塑4"];
                Data[x + 10] = (int)Reader["注废1"];
                Data[x + 11] = (int)Reader["注废2"];
                Data[x + 12] = (int)Reader["注废3"];
                Data[x + 13] = (int)Reader["注废4"];


                Data[x + 14] = (int)Reader["车丝1"];
                Data[x + 15] = (int)Reader["车丝2"];
                Data[x + 16] = (int)Reader["车丝3"];
                Data[x + 17] = (int)Reader["车丝4"];

                Data[x + 18] = (int)Reader["车废1"];
                Data[x + 19] = (int)Reader["车废2"];
                Data[x + 20] = (int)Reader["车废3"];
                Data[x + 21] = (int)Reader["车废4"];


                Data[x + 22] = (int)Reader["入库"];
                Data[x + 23] = (int)Reader["入库"];

            }
            Reader.Close();
            Reader.Dispose();
            Cmd.Dispose();
            Conn.Close();
            Conn.Dispose();
        }
    }
}
